from random import randint

from otree.api import (
    models,
    widgets,
    BaseConstants,
    BaseSubsession,
    BaseGroup,
    BasePlayer,
    Currency as c,
    currency_range,
)

author = 'Your name here'

doc = """
Your app description
"""


class Constants(BaseConstants):
    name_in_url = 'testgame'
    # players_per_group = 8
    players_per_group = 18  # 3*6
    num_rounds = 1
    # 最高分
    game_point_max = 200


class Subsession(BaseSubsession):
    # 六十个随机数 用于计算

    RandomNumber_1 = models.IntegerField(initial=0)
    RandomNumber_2 = models.IntegerField(initial=0)
    RandomNumber_3 = models.IntegerField(initial=0)
    RandomNumber_4 = models.IntegerField(initial=0)
    RandomNumber_5 = models.IntegerField(initial=0)
    RandomNumber_6 = models.IntegerField(initial=0)
    RandomNumber_7 = models.IntegerField(initial=0)
    RandomNumber_8 = models.IntegerField(initial=0)
    RandomNumber_9 = models.IntegerField(initial=0)
    RandomNumber_10 = models.IntegerField(initial=0)
    RandomNumber_11 = models.IntegerField(initial=0)
    RandomNumber_12 = models.IntegerField(initial=0)
    RandomNumber_13 = models.IntegerField(initial=0)
    RandomNumber_14 = models.IntegerField(initial=0)
    RandomNumber_15 = models.IntegerField(initial=0)
    RandomNumber_16 = models.IntegerField(initial=0)
    RandomNumber_17 = models.IntegerField(initial=0)
    RandomNumber_18 = models.IntegerField(initial=0)
    RandomNumber_19 = models.IntegerField(initial=0)
    RandomNumber_20 = models.IntegerField(initial=0)
    RandomNumber_21 = models.IntegerField(initial=0)
    RandomNumber_22 = models.IntegerField(initial=0)
    RandomNumber_23 = models.IntegerField(initial=0)
    RandomNumber_24 = models.IntegerField(initial=0)
    RandomNumber_25 = models.IntegerField(initial=0)
    RandomNumber_26 = models.IntegerField(initial=0)
    RandomNumber_27 = models.IntegerField(initial=0)
    RandomNumber_28 = models.IntegerField(initial=0)
    RandomNumber_29 = models.IntegerField(initial=0)
    RandomNumber_30 = models.IntegerField(initial=0)
    RandomNumber_31 = models.IntegerField(initial=0)
    RandomNumber_32 = models.IntegerField(initial=0)
    RandomNumber_33 = models.IntegerField(initial=0)
    RandomNumber_34 = models.IntegerField(initial=0)
    RandomNumber_35 = models.IntegerField(initial=0)
    RandomNumber_36 = models.IntegerField(initial=0)
    RandomNumber_37 = models.IntegerField(initial=0)
    RandomNumber_38 = models.IntegerField(initial=0)
    RandomNumber_39 = models.IntegerField(initial=0)
    RandomNumber_40 = models.IntegerField(initial=0)
    RandomNumber_41 = models.IntegerField(initial=0)
    RandomNumber_42 = models.IntegerField(initial=0)
    RandomNumber_43 = models.IntegerField(initial=0)
    RandomNumber_44 = models.IntegerField(initial=0)
    RandomNumber_45 = models.IntegerField(initial=0)
    RandomNumber_46 = models.IntegerField(initial=0)
    RandomNumber_47 = models.IntegerField(initial=0)
    RandomNumber_48 = models.IntegerField(initial=0)
    RandomNumber_49 = models.IntegerField(initial=0)
    RandomNumber_50 = models.IntegerField(initial=0)
    RandomNumber_51 = models.IntegerField(initial=0)
    RandomNumber_52 = models.IntegerField(initial=0)
    RandomNumber_53 = models.IntegerField(initial=0)
    RandomNumber_54 = models.IntegerField(initial=0)
    RandomNumber_55 = models.IntegerField(initial=0)
    RandomNumber_56 = models.IntegerField(initial=0)
    RandomNumber_57 = models.IntegerField(initial=0)
    RandomNumber_58 = models.IntegerField(initial=0)
    RandomNumber_59 = models.IntegerField(initial=0)
    RandomNumber_60 = models.IntegerField(initial=0)
    RandomNumber_61 = models.IntegerField(initial=0)
    RandomNumber_62 = models.IntegerField(initial=0)
    RandomNumber_63 = models.IntegerField(initial=0)
    RandomNumber_64 = models.IntegerField(initial=0)
    RandomNumber_65 = models.IntegerField(initial=0)
    RandomNumber_66 = models.IntegerField(initial=0)
    RandomNumber_67 = models.IntegerField(initial=0)
    RandomNumber_68 = models.IntegerField(initial=0)
    RandomNumber_69 = models.IntegerField(initial=0)
    RandomNumber_70 = models.IntegerField(initial=0)
    RandomNumber_71 = models.IntegerField(initial=0)
    RandomNumber_72 = models.IntegerField(initial=0)
    RandomNumber_73 = models.IntegerField(initial=0)
    RandomNumber_74 = models.IntegerField(initial=0)
    RandomNumber_75 = models.IntegerField(initial=0)
    RandomNumber_76 = models.IntegerField(initial=0)
    RandomNumber_77 = models.IntegerField(initial=0)
    RandomNumber_78 = models.IntegerField(initial=0)
    RandomNumber_79 = models.IntegerField(initial=0)
    RandomNumber_80 = models.IntegerField(initial=0)
    RandomNumber_81 = models.IntegerField(initial=0)
    RandomNumber_82 = models.IntegerField(initial=0)
    RandomNumber_83 = models.IntegerField(initial=0)
    RandomNumber_84 = models.IntegerField(initial=0)
    RandomNumber_85 = models.IntegerField(initial=0)
    RandomNumber_86 = models.IntegerField(initial=0)
    RandomNumber_87 = models.IntegerField(initial=0)
    RandomNumber_88 = models.IntegerField(initial=0)
    RandomNumber_89 = models.IntegerField(initial=0)
    RandomNumber_90 = models.IntegerField(initial=0)
    RandomNumber_91 = models.IntegerField(initial=0)
    RandomNumber_92 = models.IntegerField(initial=0)
    RandomNumber_93 = models.IntegerField(initial=0)
    RandomNumber_94 = models.IntegerField(initial=0)
    RandomNumber_95 = models.IntegerField(initial=0)
    RandomNumber_96 = models.IntegerField(initial=0)
    RandomNumber_97 = models.IntegerField(initial=0)
    RandomNumber_98 = models.IntegerField(initial=0)
    RandomNumber_99 = models.IntegerField(initial=0)
    RandomNumber_100 = models.IntegerField(initial=0)
    RandomNumber_101 = models.IntegerField(initial=0)
    RandomNumber_102 = models.IntegerField(initial=0)
    RandomNumber_103 = models.IntegerField(initial=0)
    RandomNumber_104 = models.IntegerField(initial=0)
    RandomNumber_105 = models.IntegerField(initial=0)
    RandomNumber_106 = models.IntegerField(initial=0)
    RandomNumber_107 = models.IntegerField(initial=0)
    RandomNumber_108 = models.IntegerField(initial=0)
    RandomNumber_109 = models.IntegerField(initial=0)
    RandomNumber_110 = models.IntegerField(initial=0)
    RandomNumber_111 = models.IntegerField(initial=0)
    RandomNumber_112 = models.IntegerField(initial=0)
    RandomNumber_113 = models.IntegerField(initial=0)
    RandomNumber_114 = models.IntegerField(initial=0)
    RandomNumber_115 = models.IntegerField(initial=0)
    RandomNumber_116 = models.IntegerField(initial=0)
    RandomNumber_117 = models.IntegerField(initial=0)
    RandomNumber_118 = models.IntegerField(initial=0)
    RandomNumber_119 = models.IntegerField(initial=0)
    RandomNumber_120 = models.IntegerField(initial=0)

    # 分组函数 这个分组函数是包括了随机分组的函数 后面比赛使用的分组函数只接受数据 不包括分组
    # 这里是分组分出红和蓝和绿 进行两场游戏
    # 之后还要分成小小组 用于实验
    # 生成初始随机数
    def creating_session(self):
        print("定义计算题随机值")
        numbers = []
        numbers.append(0)
        for i in range(122):  # 生成36+60个随机数加入 第一个不计入使用
            number = randint(50, 99)
            numbers.append(number)
        self.session.vars['random_numbers'] = numbers
        self.RandomNumber_1 = numbers[1]
        self.RandomNumber_2 = numbers[2]
        self.RandomNumber_3 = numbers[3]
        self.RandomNumber_4 = numbers[4]
        self.RandomNumber_5 = numbers[5]
        self.RandomNumber_6 = numbers[6]
        self.RandomNumber_7 = numbers[7]
        self.RandomNumber_8 = numbers[8]
        self.RandomNumber_9 = numbers[9]
        self.RandomNumber_10 = numbers[10]
        self.RandomNumber_11 = numbers[11]
        self.RandomNumber_12 = numbers[12]
        self.RandomNumber_13 = numbers[13]
        self.RandomNumber_14 = numbers[14]
        self.RandomNumber_15 = numbers[15]
        self.RandomNumber_16 = numbers[16]
        self.RandomNumber_17 = numbers[17]
        self.RandomNumber_18 = numbers[18]
        self.RandomNumber_19 = numbers[19]
        self.RandomNumber_20 = numbers[20]
        self.RandomNumber_21 = numbers[21]
        self.RandomNumber_22 = numbers[22]
        self.RandomNumber_23 = numbers[23]
        self.RandomNumber_24 = numbers[24]
        self.RandomNumber_25 = numbers[25]
        self.RandomNumber_26 = numbers[26]
        self.RandomNumber_27 = numbers[27]
        self.RandomNumber_28 = numbers[28]
        self.RandomNumber_29 = numbers[29]
        self.RandomNumber_30 = numbers[30]
        self.RandomNumber_31 = numbers[31]
        self.RandomNumber_32 = numbers[32]
        self.RandomNumber_33 = numbers[33]
        self.RandomNumber_34 = numbers[34]
        self.RandomNumber_35 = numbers[35]
        self.RandomNumber_36 = numbers[36]
        self.RandomNumber_37 = numbers[37]
        self.RandomNumber_38 = numbers[38]
        self.RandomNumber_39 = numbers[39]
        self.RandomNumber_40 = numbers[40]
        self.RandomNumber_41 = numbers[41]
        self.RandomNumber_42 = numbers[42]
        self.RandomNumber_43 = numbers[43]
        self.RandomNumber_44 = numbers[44]
        self.RandomNumber_45 = numbers[45]
        self.RandomNumber_46 = numbers[46]
        self.RandomNumber_47 = numbers[47]
        self.RandomNumber_48 = numbers[48]
        self.RandomNumber_49 = numbers[49]
        self.RandomNumber_50 = numbers[50]
        self.RandomNumber_51 = numbers[51]
        self.RandomNumber_52 = numbers[52]
        self.RandomNumber_53 = numbers[53]
        self.RandomNumber_54 = numbers[54]
        self.RandomNumber_55 = numbers[55]
        self.RandomNumber_56 = numbers[56]
        self.RandomNumber_57 = numbers[57]
        self.RandomNumber_58 = numbers[58]
        self.RandomNumber_59 = numbers[59]
        self.RandomNumber_60 = numbers[60]
        self.RandomNumber_61 = numbers[61]
        self.RandomNumber_62 = numbers[62]
        self.RandomNumber_63 = numbers[63]
        self.RandomNumber_64 = numbers[64]
        self.RandomNumber_65 = numbers[65]
        self.RandomNumber_66 = numbers[66]
        self.RandomNumber_67 = numbers[67]
        self.RandomNumber_68 = numbers[68]
        self.RandomNumber_69 = numbers[69]
        self.RandomNumber_70 = numbers[70]
        self.RandomNumber_71 = numbers[71]
        self.RandomNumber_72 = numbers[72]
        self.RandomNumber_73 = numbers[73]
        self.RandomNumber_74 = numbers[74]
        self.RandomNumber_75 = numbers[75]
        self.RandomNumber_76 = numbers[76]
        self.RandomNumber_77 = numbers[77]
        self.RandomNumber_78 = numbers[78]
        self.RandomNumber_79 = numbers[79]
        self.RandomNumber_80 = numbers[80]
        self.RandomNumber_81 = numbers[81]
        self.RandomNumber_82 = numbers[82]
        self.RandomNumber_83 = numbers[83]
        self.RandomNumber_84 = numbers[84]
        self.RandomNumber_85 = numbers[85]
        self.RandomNumber_86 = numbers[86]
        self.RandomNumber_87 = numbers[87]
        self.RandomNumber_88 = numbers[88]
        self.RandomNumber_89 = numbers[89]
        self.RandomNumber_90 = numbers[90]
        self.RandomNumber_91 = numbers[91]
        self.RandomNumber_92 = numbers[92]
        self.RandomNumber_93 = numbers[93]
        self.RandomNumber_94 = numbers[94]
        self.RandomNumber_95 = numbers[95]
        self.RandomNumber_96 = numbers[96]

        self.RandomNumber_97 = numbers[97]
        self.RandomNumber_98 = numbers[98]
        self.RandomNumber_99 = numbers[99]
        self.RandomNumber_100 = numbers[100]
        self.RandomNumber_101 = numbers[101]
        self.RandomNumber_102 = numbers[102]
        self.RandomNumber_103 = numbers[103]
        self.RandomNumber_104 = numbers[104]
        self.RandomNumber_105 = numbers[105]
        self.RandomNumber_106 = numbers[106]
        self.RandomNumber_107 = numbers[107]
        self.RandomNumber_108 = numbers[108]
        self.RandomNumber_109 = numbers[109]
        self.RandomNumber_110 = numbers[110]
        self.RandomNumber_110 = numbers[110]
        self.RandomNumber_111 = numbers[111]
        self.RandomNumber_112 = numbers[112]
        self.RandomNumber_113 = numbers[113]
        self.RandomNumber_114 = numbers[114]
        self.RandomNumber_115 = numbers[115]
        self.RandomNumber_116 = numbers[116]
        self.RandomNumber_117 = numbers[117]
        self.RandomNumber_118 = numbers[118]
        self.RandomNumber_119 = numbers[119]
        self.RandomNumber_120 = numbers[120]

    # 这里是分组分出红和蓝 进行两场游戏
    # 之后还要分成小小组 用于实验
    # 生成初始随机数
    # def set_initial_random_number(self):
    #     pass


class Group(BaseGroup):
    def set_initial_CalculateGamePoint(self):
        self.session.vars['A_CalculateGamePoint'] = 0
        self.session.vars['B_CalculateGamePoint'] = 0
        self.session.vars['C_CalculateGamePoint'] = 0

    def set_payoffs(self):
        players = self.get_players()
        # 如果有人选择退出游戏 那么结束比赛 退出游戏的玩家获得64货币
        # 如果有人选择退出 使用如下分支 选择退出的获得64 不选择的获得0
        powerA = 0
        powerB = 0
        powerC = 0
        # A>B>C A>C>B B>A>C B>C>A C>A>B C>B>A 1.5 1.0 0.9
        # A=B>C A=C>B B=C>A 1.5 1.5 0.9
        # A>B=C B>A=C C>A=B 1.5 1.0 1.0
        # A=B=C 1.5 1.5 1.5
        # 无论怎样 第一名都是1.5
        # 如果 第一名和第二名相等 第二名是1.5 否则第二名是1.0
        # 如果第二名和第三名相等 第三名是1.5（三个都相等）
        # 如果第三名等于第三名 那么第三名是1.0 否则第三名是0.9
        if self.session.vars['A_CalculateGamePoint'] == self.session.vars['B_CalculateGamePoint'] and self.session.vars[
            'A_CalculateGamePoint'] == self.session.vars['C_CalculateGamePoint']:
            powerA = 1.5
            powerB = 1.5
            powerC = 1.5
        elif self.session.vars['A_CalculateGamePoint'] >= self.session.vars['B_CalculateGamePoint'] and self.session.vars['A_CalculateGamePoint'] >= self.session.vars['C_CalculateGamePoint']:
            powerA = 1.5
            if self.session.vars['B_CalculateGamePoint'] == self.session.vars['C_CalculateGamePoint']:
                powerB = 1
                powerC = 1
            elif self.session.vars['A_CalculateGamePoint'] == self.session.vars['B_CalculateGamePoint']:
                powerB = 1.5
                powerC = 0.9
            elif self.session.vars['A_CalculateGamePoint'] == self.session.vars['C_CalculateGamePoint']:
                powerC = 1.5
                powerB = 0.9
            elif self.session.vars['B_CalculateGamePoint'] > self.session.vars['C_CalculateGamePoint']:
                powerB = 1
                powerC = 0.9
            else:
                powerC = 1
                powerB = 0.9

        elif self.session.vars['B_CalculateGamePoint'] >= self.session.vars['A_CalculateGamePoint'] and self.session.vars['B_CalculateGamePoint'] >= self.session.vars['C_CalculateGamePoint']:
            powerB = 1.5
            if self.session.vars['A_CalculateGamePoint'] == self.session.vars['C_CalculateGamePoint']:
                powerA = 1
                powerC = 1
            elif self.session.vars['B_CalculateGamePoint'] == self.session.vars['A_CalculateGamePoint']:
                powerA = 1.5
                powerC = 0.9
            elif self.session.vars['B_CalculateGamePoint'] == self.session.vars['C_CalculateGamePoint']:
                powerC = 1.5
                powerA = 0.9
            elif self.session.vars['A_CalculateGamePoint'] > self.session.vars['C_CalculateGamePoint']:
                powerA = 1
                powerC = 0.9
            else:
                powerC = 1
                powerA = 0.9
        elif self.session.vars['C_CalculateGamePoint'] >= self.session.vars['A_CalculateGamePoint'] and self.session.vars['C_CalculateGamePoint'] >= self.session.vars['B_CalculateGamePoint']:
            powerC = 1.5
            if self.session.vars['A_CalculateGamePoint'] == self.session.vars['B_CalculateGamePoint']:
                powerA = 1
                powerB = 1
            elif self.session.vars['C_CalculateGamePoint'] == self.session.vars['A_CalculateGamePoint']:
                powerA = 1.5
                powerB = 0.9
            elif self.session.vars['C_CalculateGamePoint'] == self.session.vars['B_CalculateGamePoint']:
                powerB = 1.5
                powerA = 0.9
            elif self.session.vars['A_CalculateGamePoint'] > self.session.vars['B_CalculateGamePoint']:
                powerA = 1
                powerB = 0.9
            else:
                powerB = 1
                powerA = 0.9

        for player in players:
            # 如果他是X队 就找X队加他六分之一的分
            point = 0
            if player.id_in_subsession == self.session.vars['r1'] or player.id_in_subsession == self.session.vars[
                'r2'] or player.id_in_subsession == self.session.vars['r3'] or player.id_in_subsession == \
                    self.session.vars['r4'] or player.id_in_subsession == self.session.vars[
                'r5'] or player.id_in_subsession == self.session.vars['r6']:
                point = round((self.session.vars['A_CalculateGamePoint']*powerA) / 6)
            if player.id_in_subsession == self.session.vars['b1'] or player.id_in_subsession == self.session.vars[
                'b2'] or player.id_in_subsession == self.session.vars['b3'] or player.id_in_subsession == \
                    self.session.vars['b4'] or player.id_in_subsession == self.session.vars[
                'b5'] or player.id_in_subsession == self.session.vars['b6']:
                point = round((self.session.vars['B_CalculateGamePoint']*powerB) / 6)
            if player.id_in_subsession == self.session.vars['g1'] or player.id_in_subsession == self.session.vars[
                'g2'] or player.id_in_subsession == self.session.vars['g3'] or player.id_in_subsession == \
                    self.session.vars['g4'] or player.id_in_subsession == self.session.vars[
                'g5'] or player.id_in_subsession == self.session.vars['g6']:
                point = round((self.session.vars['C_CalculateGamePoint']*powerC) / 6)

            player.participant.vars['total_payoff'] = 0  # 第一次 赋给用户初值0
            player.participant.vars['total_payoff'] += point  # 计算获得总金额
        # self.total_requests = sum([player.request for player in players])
        return

    # 定义初始值 如果不定义 后面增加会报错

# 生成初始资金
# def set_initial_funding(self):
#
#     players = self.get_players()
#     # participant =self.get
#     for p in players:
#         #传值给initial_funding initial_funding是participant的变量
#         #初始资金是五倍的积分
#         p.participant.vars['initial_funding']=p.game_point * 5
#
#         print(p.participant.vars['initial_funding'])

# 由于是随机分组 这里先不写
# def set_initial_group(self):
# players =self.get_players()
# for p in players:
#     game_point=p.game_point


class Player(BasePlayer):
    color = models.StringField()  # 队伍颜色 分红蓝
    game_point = models.IntegerField(initial=0,
                                     min=0, max=Constants.game_point_max, label="your game point is .......:"
                                     )
    right1 = models.IntegerField(label='', initial=0)
    right2 = models.IntegerField(label='', initial=0)
    point1 = models.IntegerField(label='', initial=0)
    point2 = models.IntegerField(label='', initial=0)
    # 初始资金
    # def set_initial_funding(self):
    #     players = self.get_players()
    #     for p in players:
    #         print("+++++++++++++++++++++++++++++++")
    #         p.initial_funding = p.point * 5

    # is_winner = models.BooleanField(initial=False)
    # 1-12是第一次 13-32是第二次
    answer_1 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_2 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_3 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_4 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_5 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_6 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_7 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_8 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_9 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_10 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_11 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_12 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_13 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_14 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_15 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_16 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_17 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_18 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_19 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_20 = models.IntegerField(label='', blank=True, initial=0, max=10000)

    answer_21 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_22 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_23 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_24 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_25 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_26 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_27 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_28 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_29 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_30 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_31 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_32 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_33 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_34 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_35 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_36 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_37 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_38 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_39 = models.IntegerField(label='', blank=True, initial=0, max=10000)
    answer_40 = models.IntegerField(label='', blank=True, initial=0, max=10000)

    # def set_payoffs(self):
    #     # 计算正确/错误 并算出分数
    #
    #
    #
    #     if self.answer_1==self.subsession.RandomNumber_1+self.subsession.RandomNumber_2+self.subsession.RandomNumber_3:
    #         print("1111")
    #
    #     # guesses = [p.guess for p in players]
    #     # two_thirds_avg = (2 / 3) * sum(guesses) / len(players)
    #     # self.two_thirds_avg = round(two_thirds_avg, 2)
    #     #
    #     # self.best_guess = min(
    #     #     guesses, key=lambda guess: abs(guess - self.two_thirds_avg)
    #     # )
    #     #
    #     # winners = [p for p in players if p.guess == self.best_guess]
    #     # self.num_winners = len(winners)
    #     #
    #     # for p in winners:
    #     #     p.is_winner = True
    #     #     p.payoff = Constants.jackpot / self.num_winners
